package com.freework.util.formula;

import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.MathContext;

import com.freework.util.NumberUtil;
public class Test {

	public static void main(String a[]){
		String str="a+c+b";

		FormulaAnalyse t=new FormulaAnalyse(str);
		Map map1=new HashMap();
		map1.put("e", "eee");

		map1.put("a", BigDecimal.ONE);
		map1.put("c",new BigDecimal(21));
		map1.put("b", BigDecimal.ONE);
		long starttime=System.currentTimeMillis();
		Formula f=	t.getFormula();
		System.out.println(f.calculateNumber(map1));
		
		
		if(true)
			return;
		for (int i = 0; i < 100; i++) {

		t.getFormula().calculateNumber(map1);
		}
		
		System.out.println(System.currentTimeMillis()-starttime);

		
		
		System.out.println(t.getFormula().calculateNumber(map1));
		TestVO values=new TestVO();
		values.setA(BigDecimal.ONE);
		values.setB(BigDecimal.ONE);
		values.setC(BigDecimal.ONE);
//		Map values=new HashMap();
//		map1.put("a", BigDecimal.ONE);
//		map1.put("b",BigDecimal.ONE);
//		map1.put("c",BigDecimal.ONE);
		String[] nameFormula={
				"ab","a+b"
				,"abc","ab+c+1"
				,"abcd","abc+d"
				,"t_1","abcd+abc+a"
				,"t_2","abcd+abc"
				,"t_3","abcd+abc"
				,"t_4","abcd+abc"
				,"t_5","abcd+abc"
				,"t_6","abcd+abc+t_3"
				,"t_7","abcd+abc+a+b+c+abc+abc+abc+abc+t_4+t_5+t_7+t_2"
				,"t_8","abcd+abc+a+b+c+t_2+t_1"
				,"t_9","abcd+abc+t_3+t_8"
				,"t_10","abcd+abc+abcd+abc+abcd+abc"
				,"t_11","abcd+abc"
				,"t_12","abcd+abc"
				,"t_13","abcd+abc"
				};
		//FormulaCalculate.calculate(nameFormula, values);
		FormulaCalculate.calculate(nameFormula, map1);

		 starttime=System.currentTimeMillis();
		for (int i = 0; i < 80000; i++) {
			FormulaCalculate.calculate(nameFormula, map1);

		}
		System.out.println(System.currentTimeMillis()-starttime);
		
		//System.out.println(map1);

		//System.out.println(values.getT_1());



	}
	
	
}
